/*
 * @Author: huangtianyang 916072572@qq.com
 * @Date: 2023-04-27 15:03:02
 * @LastEditors: huangtianyang
 * @LastEditTime: 2023-09-25 15:19:17
 * @FilePath: \cxl-admin\src\apis\operation\setMealPrice.ts
 */
import axios from '../../axios/index'

export interface setMealInterface {
    amount: string //充值金额
    id?: string
    freeCountMap?: object
    limitCount: number //限制次数
    marketAmount: string //市场价
    packageCount: number //次数
    packageName: string //套餐名称
    packageTag: string //标签
    packageNameNumber: number //套餐编号
    productType: number //套餐类型
    sort: number //排序
    status: number //状态
    validity?: number //有效期（-1.永久有效；2.十五天；3.三十天；4.六十天）
}

export const setMealAdd = (data: setMealInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/package/add',
        data
    })
}

export const setMealUpdate = (data: setMealInterface) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/package/edit',
        data
    })
}

/**
 * 启用禁用套餐
 * @param id
 * @param status 状态（0.禁用；1.启用）
 * @returns
 */
export const setMealEnabled = (id: string, status: number) => {
    return axios({
        method: 'post',
        url: '/api/mall/store/package/enable',
        data: {
            id,
            status
        }
    })
}

export interface setMealListParams {
    current: number
    size: number
    status?: number
    productType?: number
}

export const setMealList = (params: setMealListParams) => {
    return axios({
        method: 'get',
        url: '/api/mall/store/package/pageNumberPackageList',
        params
    })
}

/**
 * 删除套餐
 * @param id
 * @returns
 */
export const setMealDelete = (id: string) => {
    return axios({
        method: 'post',
        url: `/api/mall/store/package/delete/${id}`
    })
}

export const setMealDetailedById = (id: string) => {
    return axios({
        method: 'get',
        url: '/api/mall/store/package/find-by-id',
        params: { id }
    })
}
